package com.qc.bug.services.bugInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qc.bug.dao.BugInfoMapper;
import com.qc.bug.pojo.BugInfo;

@Service
public class BugInfoServicesImpl implements BugInfoServices {

	private Logger log = Logger.getLogger(BugInfoServicesImpl.class);

	@Autowired
	private BugInfoMapper bugInfoDao;

	@Override
	public void addBugInfo(BugInfo bugInfo) {
		int i = bugInfoDao.addBugInfo(bugInfo);
		if (i > 0) {
			log.debug("用户【" + bugInfo.getAddpersonid() + "】添加BUG信息成功！");
		}
	}

	@Override
	public List<Map<String, Object>> findAjaxBug(String str) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("str", str);

		return bugInfoDao.findAjaxBug(map);
	}

	@Override
	public List<Map<String, Object>> findDescription(String description,int indexPage,int pageSize) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("description", description);
		map.put("pageSize", pageSize);
		map.put("indexPage", ((indexPage - 1) * pageSize));
		
		return bugInfoDao.findDescription(map);
	}

	@Override
	public Map<String, Object> findById(int bugId) {
		return bugInfoDao.findById(bugId);
	}
}
